package com.bruce.pattern.behavioral.iterator;

import com.bruce.util.JsonUtils;
import org.junit.Test;

/**
 * Created by bruce on 2018/11/10 13:50
 */
public class MainTest {

    @Test
    public void test1(){
        CourseAggregate<Course> courseAggregate = new CourseAggregateImpl<>();
        courseAggregate.addCourse( new Course("课程1"));
        courseAggregate.addCourse( new Course("课程2"));
        courseAggregate.addCourse( new Course("课程3"));
        courseAggregate.addCourse( new Course("课程4"));
        courseAggregate.addCourse( new Course("课程5"));
        courseAggregate.addCourse( new Course("课程6"));

        CourseIterator<Course> iterator = courseAggregate.getIterator();

        while (iterator.hasNext()){
            Course next = iterator.next();
            System.out.println(JsonUtils.toJson(next));
        }


    }








}
